﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class login_change_pass : System.Web.UI.Page
{
    User u = new User();
    public string strMessage;
    bool bUpdated = false;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["username"] != null && Session["fullname"]!=null)
            {
                lUsername.Text = " " + Session["username"].ToString();
                lFullName.Text = Session["fullname"].ToString();
            }
            else Response.Redirect("login.aspx");
        }
        
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        string strPassword = string.Empty;
        string s = string.Empty;
        if (Session["username"] != null && Session["id"] != null)
        {
            User u=new User();
            if (txtNewPassword.Text == txtConfirmPassword.Text)
            {

                u.Password = txtNewPassword.Text.Trim();
                u.ID = Convert.ToInt16(Session["id"].ToString());
                u.Update_Password();
                strMessage = "Update successfull!";
                popupMessage.Show();
                bUpdated = true;
            }
            else
            {
                strMessage = "Confirm password not matching!";
                popupMessage.Show();
                bUpdated = false;
            }
          
        }
        else  Response.Redirect("login.aspx");
    }
    protected void btnOK_Click(object sender, EventArgs e)
    {
        if (bUpdated)
            Response.Redirect("login.aspx");

    }
}
